package com.wei.czz.common.enums.blog;

import com.wei.czz.common.dto.common.NameValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2024-12-04 17:15:44
 * className: BlogLabelEnum
 * version: 1.0
 * description:
 */
@Getter
@AllArgsConstructor
public enum BlogLabelEnum {

    // 博客标签值
    ORIGINAL(0, "原创"),

    REPRINT(1, "转载"),

    TRANSLATE(2, "翻译"),

    ;

    /**
     * 值
     */
    private final Integer value;

    /**
     * 名称
     */
    private final String name;

    /**
     * 获取名称
     * @param value 值
     * @return 名称
     */
    public static String getName(Integer value) {
        for (BlogLabelEnum blogLabelEnum : values()) {
            if (blogLabelEnum.value.equals(value)) {
                return blogLabelEnum.name;
            }
        }
        return "";
    }

    /**
     * 获取枚举列表
     */
    public static List<NameValue<Integer>> getList() {
        return Stream.of(values())
                .map(blogLabelEnum -> new NameValue<>(blogLabelEnum.name, blogLabelEnum.value))
                .collect(Collectors.toList());
    }
}
